package com.alan.mr;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * 自定义分组 （相同key放一起）
 * Created by Alan on 2017/10/2.
 */
public class GroupHot  extends WritableComparator{
    public GroupHot() {
        super(KeyPair.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        KeyPair o1 = (KeyPair) a;
        KeyPair o2 = (KeyPair) b;
        //默认是升序的
        int res = Integer.compare(o1.getYear(), o2.getYear());
        return res;
    }
}
